package com.doradance.app.mine;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.doradance.R;
import com.doradance.account.utils.FragmentUtils;
import com.doradance.entity.CollectDeleteEntity;
import com.doradance.entity.DeleteCollectEntity;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import org.greenrobot.eventbus.EventBus;

import butterknife.Bind;
import butterknife.OnClick;

public class MineCollectActivity extends BaseActivity {


    @Bind(R.id.tv_collect_detail)
    TextView mTvCollectDetail;
    @Bind(R.id.rl_my_delete)
    RelativeLayout mRlMyDelete;
    private String delete = "管理";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideToolbar();
        initToolsBar();
        MineCollectFragment mineCollectFragment = new MineCollectFragment();
        FragmentUtils.addFirstFragment(getSupportFragmentManager(), R.id.fl_mine_collect, mineCollectFragment);
    }

    private void initToolsBar() {

    }

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, MineCollectActivity.class);
        activity.startActivity(intent);
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_mine_collect, null);
    }

    @OnClick({R.id.iv_mycollect_back, R.id.tv_collect_detail,R.id.tv_mycollect_delete})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_mycollect_back:
                finish();
                break;
            case R.id.tv_collect_detail:
                if (mTvCollectDetail.getText().equals("管理")) {
                    mTvCollectDetail.setText("完成");
                    mRlMyDelete.setVisibility(View.VISIBLE);
                    EventBus.getDefault().post(new CollectDeleteEntity(true));
                } else {
                    EventBus.getDefault().post(new CollectDeleteEntity(false));
                    mRlMyDelete.setVisibility(View.GONE);
                    mTvCollectDetail.setText("管理");
                }
                break;
            case R.id.tv_mycollect_delete:
                    EventBus.getDefault().post(new DeleteCollectEntity());
                break;
        }
    }
}
